package yym.utils;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Init {
    private static Init init;
    private Properties properties;

    private Init() {
        String path = "src/database.properties";
        InputStream is = null;
        try {
            properties = new Properties();
            is = new FileInputStream(path);
            properties.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static  Init getInstance(){
        if (init == null){
            init = new Init();
        }
        return init;
    }

    public String getProperty(String key){
        return properties.getProperty(key);
    }
}
